package com.buanalintas.sandals.pos.pricegross;

import com.buanalintas.bynga.Dictionary;
import com.buanalintas.bynga.Field;
import com.buanalintas.bynga.Page;
import com.buanalintas.bynga.formatter.MoneyFormatter;
import com.buanalintas.sandals.pos.entities.PosMasterPriceGross;

public class PriceGross extends Page {

    private Field priceGrossId;
    private Field priceGrossName;
    private Field priceGrossQuantity;
    private Field priceGrossValue;

    public PriceGross() {
        setTheClass(PosMasterPriceGross.class);

        priceGrossId = new Field();
        priceGrossId.setName("priceGrossId");
        priceGrossId.setCaption("id");
        priceGrossId.setListProperties(" align=\"right\" width=\"5%\" nowrap");
        priceGrossId.setInputProperties(" size=\"20\"");
        getFields().add(priceGrossId);

        priceGrossName = new Field();
        priceGrossName.setName("priceGrossName");
        priceGrossName.setCaption("form");
        priceGrossName.setListProperties(" align=\"left\" width=\"10%\" nowrap");
        priceGrossName.setInputProperties(" ");
        priceGrossName.setInputType(Field.INPUT_COMBO_BOX);
        priceGrossName.getOptions().add(new String[]{"1", "STRAIGHT"});
        priceGrossName.getOptions().add(new String[]{"2", " RANDOM"});
        priceGrossName.setRequired(true);
        getFields().add(priceGrossName);

        priceGrossQuantity = new Field();
        priceGrossQuantity.setName("priceGrossQuantity");
        priceGrossQuantity.setCaption("quantity");
        priceGrossQuantity.setListProperties(" align=\"right\" width=\"10%\" nowrap");
        priceGrossQuantity.setInputProperties(" size=\"10\" ");
        priceGrossQuantity.setRequired(true);
        getFields().add(priceGrossQuantity);

        priceGrossValue = new Field();
        priceGrossValue.setName("priceGrossValue");
        priceGrossValue.setCaption("price gross");
        priceGrossValue.setListProperties(" align=\"right\" width=\"75%\" nowrap");
        priceGrossValue.setInputProperties(" size=\"10\" ");
        priceGrossValue.setFormater(MoneyFormatter.getInstance());
        priceGrossValue.setRequired(true);
        getFields().add(priceGrossValue);
        
        fillFields();

        getFieldsAdd().remove(priceGrossId);
        getFieldsEdit().remove(priceGrossId);
        getFieldsList().remove(priceGrossId);
        
        setExportList(getClass().getResourceAsStream("PriceGrossList.jasper"));
        setExport(getClass().getResourceAsStream("PriceGross.jasper"));
        getController().setOrder(priceGrossId);
    }

    @Override
    public void beforeExport() {
        getExportParams().put("title", Dictionary.getValue(this, "Price Gross"));
    }

    @Override
    public void beforeExportMulti() {
        beforeExport();
    }

}
